// components/card/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    content: {
      type: Object
    },
    apply: {
      type: Boolean,
      value: false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    reserve: [{
        title: '校区',
        content: ''
      },
      {
        title: '课程',
        content: ''
      },
      {
        title: '姓名',
        content: ''
      },
      {
        title: '电话',
        content: ''
      },
      {
        title: '时间',
        content: ''
      }
    ],
    recruit: [{
        title: '家长姓名',
        content: ''
      },
      {
        title: '宝贝姓名',
        content: ''
      },
      {
        title: '联系电话',
        content: ''
      },
      {
        title: '报名时间',
        content: ''
      },
      {
        title: '家庭地址',
        content: ''
      }
    ]
  },
  // 生命周期
  lifetimes: {
    // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
    ready() {
      this._initData()
    },
    attached: function () {},
    moved: function () {},
    detached: function () {},
  },

  /**
   * 组件的方法列表
   */
  methods: {
    // 初始化数据
    _initData() {
      const isApply = this.data.apply
      const list = isApply === true ? this.data.recruit : this.data.reserve
      const info = this.data.content
      const newInfo = Object.values(info)
      newInfo.map((item, index) => {
        list[index].content = item
      })
      isApply === true ? this.setData({
        recruit: list
      }) : this.setData({
        reserve: list
      })
    }
  }
})